<template>
	<view class="mainpadding2">
		<view class="ffffff mainpadding radius margin_top" v-for="item in list.data" :key="item.id">
			<view class="titletext xiaohei">{{item.remarks}}</view>
			<view class="flexbetween">
				<view class="xiaohui ershiba">{{item.createtime_text}}</view>
				<view class="flexright margin_top2">
					<view class="bjbtn flexcenter margin_right" @click="jumpdetail('/pages_mypage/tianjiarenwubz?type=2&id=',item.id)">
						<image class="margin_right1" style="width: 16rpx;height: 20rpx;"
							src="../static/images/system/bj.png" mode=""></image>
						<view class="ershil xiaohuang">编辑</view>
					</view>
					<view class="bjbtn flexcenter" @click.stop="currentid=item.id;showModal('是否确认删除备注？')">
						<image class="margin_right1" style="width: 16rpx;height: 20rpx;"
							src="../static/images/system/sc.png" mode=""></image>
						<view class="ershil xiaohuang">删除</view>
					</view>
				</view>
			</view>
		</view>
		<view class="gudingdb mainpadding" @click="jumpdetail('/pages_mypage/tianjiarenwubz?type=1&id=',listid)">
			<view class="bigbtn">新增备注</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				listid: "",
				modal:{
					modalShow:false,
					title:"",
				},
				currentid:"",
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.init()
		},
		methods: {
			showModal(val){
				this.modal.title = val
				this.modal.modalShow = true
			},
			modalSure(){
				if(this.modal.title=="是否确认删除备注？"){
					this.delitem()
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			delitem(){
				httpRequest.request('/api/admintask/delTaskRemarks', 'GET', {
					id: this.currentid,
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.init()
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					id: this.listid
				}
				let url = '/api/admintask/taskRemarksIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (!list.last_page) {
					return false
				}
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bjbtn {
		width: 137rpx;
		height: 58rpx;
		font-weight: 500;
		font-size: 26rpx;
		color: #FF8505;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 1rpx solid #FF8505;
	}
</style>